package com.fernfx.xingtan.common.pullrefresh;

import com.fernfx.xingtan.Constant;
import com.fernfx.xingtan.ConsumerApplication;
import com.fernfx.xingtan.common.network.IRequestCallback;
import com.fernfx.xingtan.common.network.SJJNetworkProxy;
import com.fernfx.xingtan.utils.FastJsonUtil;
import com.fernfx.xingtan.utils.OtherUtil;

import java.util.Map;

/**
 * Created by admin on 2018/8/20.
 */

public class PullToRefreshModel implements PullToRefreshContract.Model {
    @Override
    public void request(String requestUrl, Map<String, Object> requestArgsMap, IRequestCallback iRequestCallback, boolean isGet) {
        if (isGet) {
            String url = OtherUtil.getGetUrl(ConsumerApplication.ENVIRONMENT_URL + requestUrl, requestArgsMap);
            SJJNetworkProxy.getInstance().get(url, null, iRequestCallback);
        } else {
            String requestText = FastJsonUtil.BeanToJson(requestArgsMap);
            SJJNetworkProxy.getInstance().post(ConsumerApplication.ENVIRONMENT_URL + requestUrl, null, requestText, iRequestCallback);
        }
    }

    @Override
    public void returnDomain(Map<String, Object> requestArgsMap, IRequestCallback iRequestCallback) {
        String requestText = FastJsonUtil.BeanToJson(requestArgsMap);
        SJJNetworkProxy.getInstance().post(Constant.RequestArgs.VERIFY_RETURN_TERRITORY, null, requestText, iRequestCallback);

    }
}
